<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateShopAttributeMapping extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('shop_attribute_mapping', function (Blueprint $table) {
            $table->id();
            $table->unsignedInteger('shopId')->default(0)->comment('门店id');
            $table->unsignedInteger('attributeId')->default(0)->comment('门店属性值id');
            $table->string('value', 32)->default('')->comment('属性值 关联范围值数据时显示具体值');

            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedAt')->default(0)->comment('修改时间');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('修改人');
            $table->unsignedInteger('isDeleted')->default(0);

            $table->collation = 'utf8mb4_general_ci';
            $table->comment = '门店属性值关联表';

            $table->index('shopId', 'idx_shopId');
            $table->index('attributeId', 'idx_attributeId');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('shop_attribute_mapping');
    }
}
